/*
 * Copyright (C) 2006-2015
 * 版权所有者为北京捷越联合信息咨询有限公司。本系统是商用软件,未经授权擅自复制或传播本程序的部分或全部将是非法的。
 * @title: AbstractInteractExternal.java
 * @package com.jy.modules.cims.core.service.interact
 * @author zhaox
 * @date 2015-2-11 上午9:39:19
 * @version v1.00
 * @description: TODO(用一句话描述该文件做什么)
 */

package com.jy.modules.cims.interact;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jy.modules.cims.common.exception.InteractException;
import com.jy.modules.cims.data.interact.xintian.Root;

/**
 * @classname: AbstractInteractExternal
 * @description: 根据url，数据对象发送http请求
 */

public abstract class AbstractInteractExternal implements ICInteractExternalNew {

    private IClient eSBClient = ClientFactory.getCimsHttpClient();
    private static final Logger logger = LoggerFactory.getLogger(AbstractInteractExternal.class);

    @Override
    public Object send(String url, Root root) throws InteractException {
        String xml = sendBefore(root);
        logger.info("新天发送报文>>>>>>>>>>>>>>>"+xml);
      
        String ret = eSBClient.sendMsg(url, xml);
        return sendAfter(ret);
    }

    @Override
    public Object query(String url, Root root) throws InteractException {
        String xml = qeuryBefore(root);
        String ret = eSBClient.sendMsg(url, xml);
        return queryAfter(ret);
    }

    public abstract String sendBefore(Object root);

    public abstract Object sendAfter(String str);

    public abstract String qeuryBefore(Object root);

    public abstract Object queryAfter(String str);

}
